package num938;

/**
 * @author : DuJiabao
 * @Project : sword-finger-offer
 * @Time : 2021/5/9 1:14
 * @Desc :
 */
public class Solution {
  public int rangeSumBST(TreeNode root, int low, int high) {
    if (root == null) return 0;
    int val = root.val;
    if (val > high) return rangeSumBST(root.left, low, high);
    if (val < low) return rangeSumBST(root.right, low, high);
    return val + rangeSumBST(root.left, low, high) + rangeSumBST(root.right, low, high);
  }

  public static void main(String[] args) {
  }
}
